#pragma rtGlobals=1		// Use modern global access method.
function MCM_IDCheck(MCM_key,MCM_name,SpList,SpID)
// checks MCM 4 digit ID number ("key") is correct for species list
	wave MCM_key,SpID //SpID is the I.D. number of the species
	wave/t MCM_name,SpList //SpList is list of species names
	variable i
	make/o/n=(numpnts(SpList)) ID_check = -1
	note ID_check, "1 = correct name: 0 = incorrect name:"
	note ID_check, "-1 means ID number not found"
	variable PointNum
	for (i=0;i<numpnts(SpList);i+=1)
		PointNum = binarysearchinterp(MCM_key,SpID[i])
		if(mod(PointNum,1)==0) // if the species ID number is found
			ID_check[i]= stringmatch(MCM_name[PointNum],SpList[i])
		endif
	endfor
end

Function MCM_GetSpeciesKey(SpeciesList,MCM_SpeciesList,MCM_key)
	wave/t SpeciesList,MCM_SpeciesList
	wave MCM_key
	variable i
	make/o/n=(numpnts(SpeciesList)) $NameOfWave(SpeciesList)+"_key" = NaN
	wave Species_key = $NameOfWave(SpeciesList)+"_key"
	for(i=0;i<numpnts(SpeciesList);i+=1)
		FindValue/TEXT=(SpeciesList[i])/TXOP=2 MCM_SpeciesList
		if(V_value>0)
			Species_key[i] = MCM_key[V_Value]
		else
			Species_key[i] = NaN
		endif		
	endfor
end		
